package ceha.application;

import ceha.util.BackupMysql;
import ceha.util.Mysql;

import ceha.util.SystemTrayCde;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.beans.Beans;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.persistence.RollbackException;
import javax.swing.JFileChooser;
import javax.swing.JInternalFrame;
import javax.swing.JTextField;
import javax.swing.LookAndFeel;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class CEHAMain extends javax.swing.JFrame {

    private boolean login;
    private boolean loginadmin;
    private boolean fixer;
    private int largeur;
    private int hauteur;

    public JTextField getRepvignette() {
        return repvignette;
    }

    public CEHAMain() {

        //Tray icon
        new SystemTrayCde(this);

        initComponents();

//        System.out.println(getLookAndFeelsMap());
        try {

            UIManager.setLookAndFeel("WindowsLookAndFeel");
            //on passe au UIManager le nom complet de la classe du Look and Feel
            //naturellement, celle-ci doit être disponible dans le CLASSPATH
        } catch (InstantiationException e) {
        } catch (ClassNotFoundException e) {
        } catch (UnsupportedLookAndFeelException e) {
        } catch (IllegalAccessException e) {
        }

        if (checkAuto.isEnabled()) {
            pseudoField.setText(pseudoAuto.getText());
            passField.setText(passAuto.getText());
        }
        if (!Beans.isDesignTime()) {
            entityManager.getTransaction().begin();
        }
        int bord = 40;
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        largeur = screenSize.width - bord * 2;
        hauteur = screenSize.height - bord * 2;
        setBounds(bord, bord, largeur, hauteur);

        loginJInternalFrame.setLocation(0, 0);

//        try {
//            loginJInternalFrame.setSelected(true);
//        } catch (java.beans.PropertyVetoException e) {
//        }

        consultJInternalFrame.setLocation(300, 0);
        //        try {
        //            consultJInternalFrame.setSelected(true);
        //        } catch (java.beans.PropertyVetoException e) {
        //        }




    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("BDDCEHAPU").createEntityManager();
        query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery("SELECT f FROM Fiche f");
        list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
        desktop = new javax.swing.JDesktopPane();
        loginJInternalFrame = new javax.swing.JInternalFrame();
        loginPanel = new javax.swing.JPanel();
        passField = new javax.swing.JPasswordField();
        pseudoLabel = new javax.swing.JLabel();
        pseudoField = new javax.swing.JTextField();
        deconnection = new javax.swing.JButton();
        passLabel = new javax.swing.JLabel();
        loginButton = new javax.swing.JButton();
        logoLabel = new javax.swing.JLabel();
        bienvenueLabel = new javax.swing.JLabel();
        adminJInternalFrame = new javax.swing.JInternalFrame();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        optionsPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        repvignette = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        droitsButton = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        pseudoAuto = new javax.swing.JTextField();
        passAuto = new javax.swing.JPasswordField();
        jLabel7 = new javax.swing.JLabel();
        checkAuto = new javax.swing.JCheckBox();
        gestionnaireField = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        backupBase = new javax.swing.JPanel();
        dossiersave = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        choixButon = new javax.swing.JButton();
        nomsave = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        lancerButton = new javax.swing.JButton();
        consultJInternalFrame = new javax.swing.JInternalFrame();
        createPanel = new javax.swing.JPanel();
        consult = new javax.swing.JButton();
        actionJInternalFrame = new javax.swing.JInternalFrame();
        createPanel1 = new javax.swing.JPanel();
        adminButton = new javax.swing.JButton();
        creerButton = new javax.swing.JButton();
        controleValideButton = new javax.swing.JButton();
        droitsUtilisateursJInternalFrame = new javax.swing.JInternalFrame();
        jPanel1 = new javax.swing.JPanel();
        masterScrollPane = new javax.swing.JScrollPane();
        masterTable = new javax.swing.JTable();
        idLabel = new javax.swing.JLabel();
        pseudoLabel1 = new javax.swing.JLabel();
        passLabel1 = new javax.swing.JLabel();
        nomLabel = new javax.swing.JLabel();
        prenomLabel = new javax.swing.JLabel();
        initialeLabel = new javax.swing.JLabel();
        roleLabel = new javax.swing.JLabel();
        consultLabel = new javax.swing.JLabel();
        indexationLabel = new javax.swing.JLabel();
        validationLabel = new javax.swing.JLabel();
        administLabel = new javax.swing.JLabel();
        idField = new javax.swing.JTextField();
        pseudoField1 = new javax.swing.JTextField();
        passField1 = new javax.swing.JTextField();
        nomField = new javax.swing.JTextField();
        prenomField = new javax.swing.JTextField();
        initialeField = new javax.swing.JTextField();
        roleField = new javax.swing.JTextField();
        consultField = new javax.swing.JTextField();
        indexationField = new javax.swing.JTextField();
        validationField = new javax.swing.JTextField();
        administField = new javax.swing.JTextField();
        saveButton = new javax.swing.JButton();
        refreshButton = new javax.swing.JButton();
        newButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        consultJInternalFrame1 = new javax.swing.JInternalFrame();
        createPanel2 = new javax.swing.JPanel();
        consult1 = new javax.swing.JButton();
        menubar1 = new javax.swing.JMenuBar();
        mainmenu = new javax.swing.JMenu();
        quitte = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("BDD DU CEHA");
        setAlwaysOnTop(true);
        setBackground(new java.awt.Color(0, 0, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        desktop.setBackground(new java.awt.Color(255, 255, 255));
        desktop.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
        desktop.setForeground(new java.awt.Color(0, 0, 0));
        desktop.setDragMode(javax.swing.JDesktopPane.OUTLINE_DRAG_MODE);
        desktop.setSelectedFrame(loginJInternalFrame);

        loginJInternalFrame.setIconifiable(true);
        loginJInternalFrame.setTitle("LOGIN");
        loginJInternalFrame.setVisible(true);

        loginPanel.setBackground(new java.awt.Color(255, 255, 255));
        loginPanel.setBorder(javax.swing.BorderFactory.createEtchedBorder(new java.awt.Color(255, 255, 153), new java.awt.Color(102, 102, 102)));

        passField.setBackground(new java.awt.Color(255, 255, 204));
        passField.setFont(new java.awt.Font("Arial", 1, 12));
        passField.setToolTipText("laissez les champs vides pour une simple recherche");
        passField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 51, 255), new java.awt.Color(204, 255, 255), null, null));

        pseudoLabel.setBackground(new java.awt.Color(0, 0, 0));
        pseudoLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        pseudoLabel.setForeground(new java.awt.Color(255, 255, 255));
        pseudoLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        pseudoLabel.setText("Pseudo ");
        pseudoLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        pseudoLabel.setOpaque(true);

        pseudoField.setBackground(new java.awt.Color(255, 255, 204));
        pseudoField.setFont(new java.awt.Font("Arial", 1, 12));
        pseudoField.setToolTipText("");
        pseudoField.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 102, 255), new java.awt.Color(204, 255, 255), null, null));

        deconnection.setBackground(new java.awt.Color(255, 255, 255));
        deconnection.setFont(new java.awt.Font("Times New Roman", 1, 14));
        deconnection.setText("LOGOUT");
        deconnection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                logoutButton(evt);
            }
        });

        passLabel.setBackground(new java.awt.Color(0, 0, 0));
        passLabel.setFont(new java.awt.Font("Tahoma", 1, 14));
        passLabel.setForeground(new java.awt.Color(255, 255, 255));
        passLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        passLabel.setText("Mot de passe");
        passLabel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        passLabel.setOpaque(true);

        loginButton.setBackground(new java.awt.Color(255, 255, 204));
        loginButton.setFont(new java.awt.Font("Times New Roman", 1, 14));
        loginButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/login.jpg"))); // NOI18N
        loginButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 102, 102), 5, true), "Login", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 18), new java.awt.Color(0, 102, 102))); // NOI18N
        loginButton.setContentAreaFilled(false);
        loginButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                loginButton(evt);
            }
        });

        logoLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/logoCEHA.jpg"))); // NOI18N

        bienvenueLabel.setFont(new java.awt.Font("Palatino Linotype", 3, 18));
        bienvenueLabel.setForeground(new java.awt.Color(255, 255, 255));
        bienvenueLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        bienvenueLabel.setText("BIENVENUE !");
        bienvenueLabel.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 1, true));

        javax.swing.GroupLayout loginPanelLayout = new javax.swing.GroupLayout(loginPanel);
        loginPanel.setLayout(loginPanelLayout);
        loginPanelLayout.setHorizontalGroup(
            loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(loginPanelLayout.createSequentialGroup()
                        .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, loginPanelLayout.createSequentialGroup()
                                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(passLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE)
                                    .addComponent(pseudoLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(pseudoField)
                                    .addComponent(passField, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, loginPanelLayout.createSequentialGroup()
                                .addComponent(logoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(loginButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, loginPanelLayout.createSequentialGroup()
                        .addComponent(deconnection, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(67, 67, 67))
                    .addGroup(loginPanelLayout.createSequentialGroup()
                        .addComponent(bienvenueLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 256, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        loginPanelLayout.setVerticalGroup(
            loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pseudoLabel)
                    .addComponent(pseudoField, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(passField)
                    .addComponent(passLabel))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(loginPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(logoLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(loginButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deconnection)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(bienvenueLabel)
                .addGap(66, 66, 66))
        );

        loginJInternalFrame.getContentPane().add(loginPanel, java.awt.BorderLayout.CENTER);

        loginJInternalFrame.setBounds(30, 10, 280, 290);
        desktop.add(loginJInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        adminJInternalFrame.setIconifiable(true);

        jTabbedPane1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        optionsPanel.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        optionsPanel.setFont(new java.awt.Font("Tahoma", 1, 11));

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setForeground(new java.awt.Color(255, 0, 0));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Répertoire des vignettes");

        repvignette.setBackground(new java.awt.Color(255, 255, 204));
        repvignette.setFont(new java.awt.Font("Tahoma", 1, 14));
        repvignette.setText("C:\\Documents and Settings\\Gilles\\ImageCeha");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel2.setForeground(new java.awt.Color(255, 0, 0));
        jLabel2.setText("Droits des membres");

        droitsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/gestion-droits.gif"))); // NOI18N
        droitsButton.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        droitsButton.setContentAreaFilled(false);
        droitsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                droitsButton(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel5.setForeground(new java.awt.Color(255, 0, 0));
        jLabel5.setText("Login automatique");

        jLabel6.setBackground(new java.awt.Color(0, 0, 0));
        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Pseudo ");
        jLabel6.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel6.setOpaque(true);

        pseudoAuto.setBackground(new java.awt.Color(255, 255, 204));
        pseudoAuto.setFont(new java.awt.Font("Arial", 1, 12));
        pseudoAuto.setText("ceha");
        pseudoAuto.setToolTipText("");
        pseudoAuto.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 102, 255), new java.awt.Color(204, 255, 255), null, null));

        passAuto.setBackground(new java.awt.Color(255, 255, 204));
        passAuto.setFont(new java.awt.Font("Arial", 1, 12));
        passAuto.setText("ceha");
        passAuto.setToolTipText("laissez les champs vides pour une simple recherche");
        passAuto.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.LOWERED, new java.awt.Color(51, 51, 255), new java.awt.Color(204, 255, 255), null, null));

        jLabel7.setBackground(new java.awt.Color(0, 0, 0));
        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Mot de passe");
        jLabel7.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jLabel7.setOpaque(true);

        checkAuto.setFont(new java.awt.Font("Tahoma", 1, 11));
        checkAuto.setSelected(true);
        checkAuto.setText("valide");

        gestionnaireField.setBackground(new java.awt.Color(204, 255, 204));
        gestionnaireField.setFont(new java.awt.Font("Tahoma", 1, 14));
        gestionnaireField.setText("C://wamp//wampmanager.exe");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel8.setForeground(new java.awt.Color(255, 0, 0));
        jLabel8.setText("Gestionnaire serveur MySql");

        javax.swing.GroupLayout optionsPanelLayout = new javax.swing.GroupLayout(optionsPanel);
        optionsPanel.setLayout(optionsPanelLayout);
        optionsPanelLayout.setHorizontalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(pseudoAuto)
                            .addComponent(passAuto, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(345, 345, 345))
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(repvignette, javax.swing.GroupLayout.DEFAULT_SIZE, 402, Short.MAX_VALUE)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, optionsPanelLayout.createSequentialGroup()
                                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(droitsButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                .addGap(18, 18, 18)
                                .addComponent(checkAuto))
                            .addComponent(gestionnaireField))
                        .addGap(199, 199, 199))
                    .addGroup(optionsPanelLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addContainerGap(332, Short.MAX_VALUE))))
        );
        optionsPanelLayout.setVerticalGroup(
            optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(optionsPanelLayout.createSequentialGroup()
                .addGap(47, 47, 47)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(repvignette, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(gestionnaireField, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(droitsButton, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(checkAuto))
                .addGap(18, 18, 18)
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(pseudoAuto, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(optionsPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(passAuto, javax.swing.GroupLayout.DEFAULT_SIZE, 21, Short.MAX_VALUE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42))
        );

        jTabbedPane1.addTab("Options générales", optionsPanel);

        backupBase.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));

        dossiersave.setFont(new java.awt.Font("Times New Roman", 1, 14));

        jLabel3.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel3.setText("Dossier de souvegarde (externe)");

        choixButon.setFont(new java.awt.Font("Times New Roman", 1, 14));
        choixButon.setText("Choisir");
        choixButon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                choixrepButton(evt);
            }
        });

        nomsave.setFont(new java.awt.Font("Times New Roman", 1, 14));

        jLabel4.setFont(new java.awt.Font("Times New Roman", 1, 18));
        jLabel4.setText("Nom de la sauvegarde");

        lancerButton.setFont(new java.awt.Font("Times New Roman", 1, 14));
        lancerButton.setForeground(new java.awt.Color(153, 0, 0));
        lancerButton.setText("Lancer la sauvegarde");
        lancerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                backupButton(evt);
            }
        });

        javax.swing.GroupLayout backupBaseLayout = new javax.swing.GroupLayout(backupBase);
        backupBase.setLayout(backupBaseLayout);
        backupBaseLayout.setHorizontalGroup(
            backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(backupBaseLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(backupBaseLayout.createSequentialGroup()
                        .addGroup(backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addGroup(backupBaseLayout.createSequentialGroup()
                                .addGroup(backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(nomsave, javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(dossiersave, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(choixButon, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(94, Short.MAX_VALUE))
                    .addGroup(backupBaseLayout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(327, 327, 327))
                    .addGroup(backupBaseLayout.createSequentialGroup()
                        .addComponent(lancerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 180, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        backupBaseLayout.setVerticalGroup(
            backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(backupBaseLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(backupBaseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(dossiersave, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(choixButon, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel4)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(nomsave, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(lancerButton, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(186, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("BackUp BDD", backupBase);

        javax.swing.GroupLayout adminJInternalFrameLayout = new javax.swing.GroupLayout(adminJInternalFrame.getContentPane());
        adminJInternalFrame.getContentPane().setLayout(adminJInternalFrameLayout);
        adminJInternalFrameLayout.setHorizontalGroup(
            adminJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(adminJInternalFrameLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE))
        );
        adminJInternalFrameLayout.setVerticalGroup(
            adminJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(adminJInternalFrameLayout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 412, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(43, Short.MAX_VALUE))
        );

        adminJInternalFrame.setBounds(520, 190, 530, 490);
        desktop.add(adminJInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        consultJInternalFrame.setIconifiable(true);
        consultJInternalFrame.setTitle("CONSULTATION");
        consultJInternalFrame.setVisible(true);

        createPanel.setBackground(new java.awt.Color(255, 255, 255));
        createPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 0), new java.awt.Color(255, 255, 204), new java.awt.Color(102, 102, 102), new java.awt.Color(255, 255, 255)));

        consult.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
        consult.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/consultation.gif"))); // NOI18N
        consult.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 51, 255), 5, true), "Consulter les LISTES", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 3, 18), new java.awt.Color(0, 0, 0))); // NOI18N
        consult.setContentAreaFilled(false);
        consult.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/40px-Light_green_check.svg.png"))); // NOI18N
        consult.setFocusable(false);
        consult.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        consult.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        consult.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consultButton(evt);
            }
        });

        javax.swing.GroupLayout createPanelLayout = new javax.swing.GroupLayout(createPanel);
        createPanel.setLayout(createPanelLayout);
        createPanelLayout.setHorizontalGroup(
            createPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consult, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );
        createPanelLayout.setVerticalGroup(
            createPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consult, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        consultJInternalFrame.getContentPane().add(createPanel, java.awt.BorderLayout.CENTER);

        consultJInternalFrame.setBounds(690, 30, 250, 140);
        desktop.add(consultJInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        actionJInternalFrame.setIconifiable(true);

        createPanel1.setBackground(new java.awt.Color(255, 255, 255));
        createPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 0), new java.awt.Color(255, 255, 204), new java.awt.Color(102, 102, 102), new java.awt.Color(255, 255, 255)));
        createPanel1.setForeground(new java.awt.Color(255, 255, 255));

        adminButton.setFont(new java.awt.Font("Times New Roman", 3, 18));
        adminButton.setText("Administrer");
        adminButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(153, 0, 0), 5, true));
        adminButton.setContentAreaFilled(false);
        adminButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                adminButton(evt);
            }
        });

        creerButton.setFont(new java.awt.Font("Tahoma", 1, 12));
        creerButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/fiche.jpg"))); // NOI18N
        creerButton.setToolTipText("N'entrez rien pour une simple recherche dans la base");
        creerButton.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(51, 102, 0), 5, true), "Créer des fiches", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 1, 18), new java.awt.Color(0, 0, 0))); // NOI18N
        creerButton.setContentAreaFilled(false);
        creerButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                creerFichesButton(evt);
            }
        });

        controleValideButton.setFont(new java.awt.Font("Times New Roman", 3, 18));
        controleValideButton.setText("Contrôler et Valider");
        controleValideButton.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 5, true));
        controleValideButton.setContentAreaFilled(false);
        controleValideButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                controleValideButton(evt);
            }
        });

        javax.swing.GroupLayout createPanel1Layout = new javax.swing.GroupLayout(createPanel1);
        createPanel1.setLayout(createPanel1Layout);
        createPanel1Layout.setHorizontalGroup(
            createPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, createPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addComponent(creerButton, javax.swing.GroupLayout.DEFAULT_SIZE, 169, Short.MAX_VALUE)
                .addGap(26, 26, 26))
            .addGroup(createPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(controleValideButton, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(createPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(adminButton, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
                .addContainerGap())
        );
        createPanel1Layout.setVerticalGroup(
            createPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(creerButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
                .addComponent(adminButton)
                .addGap(18, 18, 18)
                .addComponent(controleValideButton)
                .addGap(23, 23, 23))
        );

        javax.swing.GroupLayout actionJInternalFrameLayout = new javax.swing.GroupLayout(actionJInternalFrame.getContentPane());
        actionJInternalFrame.getContentPane().setLayout(actionJInternalFrameLayout);
        actionJInternalFrameLayout.setHorizontalGroup(
            actionJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 341, Short.MAX_VALUE)
            .addGroup(actionJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(actionJInternalFrameLayout.createSequentialGroup()
                    .addGap(0, 56, Short.MAX_VALUE)
                    .addComponent(createPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 56, Short.MAX_VALUE)))
        );
        actionJInternalFrameLayout.setVerticalGroup(
            actionJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 295, Short.MAX_VALUE)
            .addGroup(actionJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(actionJInternalFrameLayout.createSequentialGroup()
                    .addGap(0, 34, Short.MAX_VALUE)
                    .addComponent(createPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 35, Short.MAX_VALUE)))
        );

        actionJInternalFrame.setBounds(60, 370, 350, 330);
        desktop.add(actionJInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        droitsUtilisateursJInternalFrame.setIconifiable(true);

        masterScrollPane.setViewportView(masterTable);

        idLabel.setText("Id:");

        pseudoLabel1.setText("Pseudo:");

        passLabel1.setText("Pass:");

        nomLabel.setText("Nom:");

        prenomLabel.setText("Prenom:");

        initialeLabel.setText("Initiale:");

        roleLabel.setText("Role:");

        consultLabel.setText("Consult:");

        indexationLabel.setText("Indexation:");

        validationLabel.setText("Validation:");

        administLabel.setText("Administ:");

        saveButton.setText("Save");
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        refreshButton.setText("Refresh");
        refreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshButtonActionPerformed(evt);
            }
        });

        newButton.setText("New");
        newButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newButtonActionPerformed(evt);
            }
        });

        deleteButton.setText("Delete");
        deleteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(newButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(refreshButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(saveButton))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(idLabel)
                            .addComponent(pseudoLabel1)
                            .addComponent(passLabel1)
                            .addComponent(nomLabel)
                            .addComponent(prenomLabel)
                            .addComponent(initialeLabel)
                            .addComponent(roleLabel)
                            .addComponent(consultLabel)
                            .addComponent(indexationLabel)
                            .addComponent(validationLabel)
                            .addComponent(administLabel))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(idField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(pseudoField1, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(passField1, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(nomField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(prenomField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(initialeField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(roleField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(consultField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(indexationField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(validationField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                            .addComponent(administField, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(masterScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 529, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 130, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(idLabel)
                    .addComponent(idField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(pseudoLabel1)
                    .addComponent(pseudoField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(passLabel1)
                    .addComponent(passField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nomLabel)
                    .addComponent(nomField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(prenomLabel)
                    .addComponent(prenomField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(initialeLabel)
                    .addComponent(initialeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(roleLabel)
                    .addComponent(roleField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(consultLabel)
                    .addComponent(consultField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(indexationLabel)
                    .addComponent(indexationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(validationLabel)
                    .addComponent(validationField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(administLabel)
                    .addComponent(administField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(saveButton)
                    .addComponent(refreshButton)
                    .addComponent(deleteButton)
                    .addComponent(newButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout droitsUtilisateursJInternalFrameLayout = new javax.swing.GroupLayout(droitsUtilisateursJInternalFrame.getContentPane());
        droitsUtilisateursJInternalFrame.getContentPane().setLayout(droitsUtilisateursJInternalFrameLayout);
        droitsUtilisateursJInternalFrameLayout.setHorizontalGroup(
            droitsUtilisateursJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 549, Short.MAX_VALUE)
            .addGroup(droitsUtilisateursJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(droitsUtilisateursJInternalFrameLayout.createSequentialGroup()
                    .addGap(0, 0, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 0, Short.MAX_VALUE)))
        );
        droitsUtilisateursJInternalFrameLayout.setVerticalGroup(
            droitsUtilisateursJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 703, Short.MAX_VALUE)
            .addGroup(droitsUtilisateursJInternalFrameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(droitsUtilisateursJInternalFrameLayout.createSequentialGroup()
                    .addGap(0, 118, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(0, 118, Short.MAX_VALUE)))
        );

        droitsUtilisateursJInternalFrame.setBounds(0, 0, 558, 742);
        desktop.add(droitsUtilisateursJInternalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);

        consultJInternalFrame1.setIconifiable(true);
        consultJInternalFrame1.setTitle("CONSULTATION");
        consultJInternalFrame1.setVisible(true);

        createPanel2.setBackground(new java.awt.Color(255, 255, 255));
        createPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(255, 204, 0), new java.awt.Color(255, 255, 204), new java.awt.Color(102, 102, 102), new java.awt.Color(255, 255, 255)));

        consult1.setFont(new java.awt.Font("Times New Roman", 3, 14)); // NOI18N
        consult1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/consultation.gif"))); // NOI18N
        consult1.setBorder(javax.swing.BorderFactory.createTitledBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 51, 255), 5, true), "Consulter les FICHES", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 3, 18), new java.awt.Color(0, 0, 0))); // NOI18N
        consult1.setContentAreaFilled(false);
        consult1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/40px-Light_green_check.svg.png"))); // NOI18N
        consult1.setFocusable(false);
        consult1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        consult1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        consult1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                consult1Button(evt);
            }
        });

        javax.swing.GroupLayout createPanel2Layout = new javax.swing.GroupLayout(createPanel2);
        createPanel2.setLayout(createPanel2Layout);
        createPanel2Layout.setHorizontalGroup(
            createPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consult1, javax.swing.GroupLayout.DEFAULT_SIZE, 217, Short.MAX_VALUE)
                .addContainerGap())
        );
        createPanel2Layout.setVerticalGroup(
            createPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(createPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(consult1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );

        consultJInternalFrame1.getContentPane().add(createPanel2, java.awt.BorderLayout.CENTER);

        consultJInternalFrame1.setBounds(370, 30, 250, 140);
        desktop.add(consultJInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menubar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        menubar1.setFont(new java.awt.Font("Times New Roman", 1, 14));

        mainmenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ceha/ressource/petitlogoCEHA.jpg"))); // NOI18N
        mainmenu.setText("CEHA");
        mainmenu.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        quitte.setText("Quitter");
        quitte.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                quitteActionPerformed(evt);
            }
        });
        mainmenu.add(quitte);

        menubar1.add(mainmenu);

        jMenu1.setText("Outils");
        menubar1.add(jMenu1);

        setJMenuBar(menubar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktop, javax.swing.GroupLayout.DEFAULT_SIZE, 1024, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktop, javax.swing.GroupLayout.DEFAULT_SIZE, 739, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void quitteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_quitteActionPerformed
        System.exit(0);
    }//GEN-LAST:event_quitteActionPerformed

    private void logoutButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButton
        login = false;
        pseudoField.setText("");
        passField.setText("");
        pseudoField.setBackground(new Color(255, 255, 204));
        passField.setBackground(new Color(255, 255, 204));
        actionJInternalFrame.dispose();
//        actionJInternalFrame.getCreationFichesWin().dispose();
}//GEN-LAST:event_logoutButton

    private void loginButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButton
        String nom = pseudoField.getText();
        String mot = passField.getText();
        Connection conn = null;
        try {
            conn = new Mysql().Connect();// conn = new Mysql(adminparam).Connect();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        Statement stmt;
        ResultSet res = null;
        List<String> Lpseudo = new ArrayList<String>();
        List<String> Lpass = new ArrayList<String>();
        //        List<String> Lrole = new ArrayList<String>();
        List<Boolean> Lconsult = new ArrayList<Boolean>();
        List<Boolean> Lindex = new ArrayList<Boolean>();
        List<Boolean> Lvalid = new ArrayList<Boolean>();
        List<Boolean> Ladmin = new ArrayList<Boolean>();
        try {
            stmt = conn.createStatement();
            res = stmt.executeQuery("SELECT * FROM membre");
            while (res.next()) {
                Lpseudo.add(res.getString("pseudo"));
                Lpass.add(res.getString("pass"));
                //obsolete            //Lrole.add(res.getString("role"));
                Lconsult.add(res.getBoolean("consult"));
                Lindex.add(res.getBoolean("indexation"));
                Lvalid.add(res.getBoolean("validation"));
                Ladmin.add(res.getBoolean("administ"));
            }
            res.close();
            stmt.close();
            conn.close();

        } catch (SQLException e) {
            e.printStackTrace();
        }
        int no = 0;
        while (no < Lpseudo.size()) {
            if ((Lpseudo.get(no).equals(nom)) && (Lpass.get(no).equals(mot))) {
                if ((Lconsult.get(no)) && (Lvalid.get(no)) && (Lindex.get(no))) {
                    pseudoField.setBackground(Color.green);
                    passField.setBackground(Color.green);
                    login = true; // login "normal"
                    bienvenueLabel.setForeground(Color.BLACK);

                    if (Ladmin.get(no)) {
                        // login admin
                        loginadmin = true;

                    }

                    actionJInternalFrame.setVisible(true);
                    actionJInternalFrame.setLocation(0, 350);
                }
                break;
            } else {
                no++;
            }
            login = false; //pas de login
            pseudoField.setBackground(Color.red);
            passField.setBackground(Color.red);
        }
}//GEN-LAST:event_loginButton

    private void droitsButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_droitsButton

        droitsUtilisateursJInternalFrame.setVisible(true);
//        desktop.add(droitsUtilisateursJInternalFrame);
//        try {
//            droitsUtilisateursJInternalFrame.setSelected(true);
//        } catch (java.beans.PropertyVetoException e) {
//        }
}//GEN-LAST:event_droitsButton

    private void choixrepButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_choixrepButton

        JFileChooser chooser = new JFileChooser();
        chooser.setCurrentDirectory(new java.io.File("."));
        chooser.setDialogTitle("choosertitle");
        chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        chooser.setAcceptAllFileFilterUsed(false);
        if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
            dossiersave.setText(chooser.getCurrentDirectory().getAbsolutePath() + "\\");
            //            System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
            //            System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
        }
}//GEN-LAST:event_choixrepButton

    private void backupButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backupButton
        if (!nomsave.getText().equals("")) {
            try {
                //            Connection connection = new Mysql().Connect();
                new BackupMysql(dossiersave.getText() + nomsave.getText() + ".zip");
            } catch (FileNotFoundException ex) {
                ex.printStackTrace();
            } catch (IOException ex) {
                ex.printStackTrace();
            } catch (Exception ex) {
                ex.printStackTrace();
            }

        }
}//GEN-LAST:event_backupButton

    private void consultButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consultButton

        CEHAData data = new CEHAData();
        JInternalFrame gdata = data.getDonneesTablesJIF();
        gdata.setVisible(true);
        gdata.setLocation(0, 300);
        gdata.setSize(largeur - 50, 400);
        desktop.add(gdata);
    }//GEN-LAST:event_consultButton

    private void adminButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_adminButton
        if (loginadmin) {
            adminJInternalFrame.setVisible(true);
//            desktop.add(adminJInternalFrame);
//            try {
//                adminJInternalFrame.setSelected(true);
//            } catch (java.beans.PropertyVetoException e) {
//            }
        }
}//GEN-LAST:event_adminButton

    private void creerFichesButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_creerFichesButton
         CEHAData data = new CEHAData();
  CEHAFicheCreation fiche = new CEHAFicheCreation(this,data);
        JInternalFrame gfiche= fiche.getFicheAcreerJIF();
        gfiche.setVisible(true);
//        gfiche.setLocation(0, 300);
//        gfiche.setSize(largeur - 50, 400);
        desktop.add(gfiche);
    }//GEN-LAST:event_creerFichesButton

    private void controleValideButton(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_controleValideButton
        //        if (login) {
        //            JFrame frame = new JFrame("BDD CEHA Formulaire");
        //            CreationMasterDetailForm master = new CreationMasterDetailForm(this);
        //            master.getCommandes().setVisible(true);
        //            master.add(master.getCommandes());
        //            master.getAdminpanel().setVisible(flagadmin);
        //            master.getFormulaire().setVisible(true);
        //            frame.setContentPane(master);
        //            frame.pack();
        //            frame.setVisible(true);
        //
        //        } else {
        //            this.message = "Login nécessaire !";
        //            new OkDialog(this, true).setVisible(true);
        //        }
}//GEN-LAST:event_controleValideButton

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        try {
            entityManager.getTransaction().commit();
            entityManager.getTransaction().begin();
        } catch (RollbackException rex) {
            rex.printStackTrace();
            entityManager.getTransaction().begin();
            List<ceha.Fiche> merged = new ArrayList<ceha.Fiche>(list.size());
            for (ceha.Fiche m : list) {
                merged.add(entityManager.merge(m));
            }
            list.clear();
            list.addAll(merged);
        }
}//GEN-LAST:event_saveButtonActionPerformed

    private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshButtonActionPerformed
        entityManager.getTransaction().rollback();
        entityManager.getTransaction().begin();
        java.util.Collection data = query.getResultList();
        for (Object entity : data) {
            entityManager.refresh(entity);
        }
        list.clear();
        list.addAll(data);
}//GEN-LAST:event_refreshButtonActionPerformed

    private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
        ceha.Fiche m = new ceha.Fiche();
        entityManager.persist(m);
        list.add(m);
        int row = list.size() - 1;
        masterTable.setRowSelectionInterval(row, row);
        masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
}//GEN-LAST:event_newButtonActionPerformed

    private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed
        int[] selected = masterTable.getSelectedRows();
        List<ceha.Fiche> toRemove = new ArrayList<ceha.Fiche>(selected.length);
        for (int idx = 0; idx < selected.length; idx++) {
            ceha.Fiche m = list.get(masterTable.convertRowIndexToModel(selected[idx]));
            toRemove.add(m);
            entityManager.remove(m);
        }
        list.removeAll(toRemove);
}//GEN-LAST:event_deleteButtonActionPerformed

    private void consult1Button(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_consult1Button
        // TODO add your handling code here:
    }//GEN-LAST:event_consult1Button

    public static void main(String args[]) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {

            public void run() {
                CEHAMain frame = new CEHAMain();
                frame.setVisible(true);

            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JInternalFrame actionJInternalFrame;
    private javax.swing.JButton adminButton;
    private javax.swing.JInternalFrame adminJInternalFrame;
    private javax.swing.JTextField administField;
    private javax.swing.JLabel administLabel;
    private javax.swing.JPanel backupBase;
    private javax.swing.JLabel bienvenueLabel;
    private javax.swing.JCheckBox checkAuto;
    private javax.swing.JButton choixButon;
    private javax.swing.JButton consult;
    private javax.swing.JButton consult1;
    private javax.swing.JTextField consultField;
    private javax.swing.JInternalFrame consultJInternalFrame;
    private javax.swing.JInternalFrame consultJInternalFrame1;
    private javax.swing.JLabel consultLabel;
    private javax.swing.JButton controleValideButton;
    private javax.swing.JPanel createPanel;
    private javax.swing.JPanel createPanel1;
    private javax.swing.JPanel createPanel2;
    private javax.swing.JButton creerButton;
    private javax.swing.JButton deconnection;
    private javax.swing.JButton deleteButton;
    private javax.swing.JDesktopPane desktop;
    private javax.swing.JTextField dossiersave;
    private javax.swing.JButton droitsButton;
    private javax.swing.JInternalFrame droitsUtilisateursJInternalFrame;
    private javax.persistence.EntityManager entityManager;
    private javax.swing.JTextField gestionnaireField;
    private javax.swing.JTextField idField;
    private javax.swing.JLabel idLabel;
    private javax.swing.JTextField indexationField;
    private javax.swing.JLabel indexationLabel;
    private javax.swing.JTextField initialeField;
    private javax.swing.JLabel initialeLabel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton lancerButton;
    private java.util.List<ceha.Fiche> list;
    private javax.swing.JButton loginButton;
    private javax.swing.JInternalFrame loginJInternalFrame;
    private javax.swing.JPanel loginPanel;
    private javax.swing.JLabel logoLabel;
    private javax.swing.JMenu mainmenu;
    private javax.swing.JScrollPane masterScrollPane;
    private javax.swing.JTable masterTable;
    private javax.swing.JMenuBar menubar1;
    private javax.swing.JButton newButton;
    private javax.swing.JTextField nomField;
    private javax.swing.JLabel nomLabel;
    private javax.swing.JTextField nomsave;
    private javax.swing.JPanel optionsPanel;
    private javax.swing.JPasswordField passAuto;
    private javax.swing.JPasswordField passField;
    private javax.swing.JTextField passField1;
    private javax.swing.JLabel passLabel;
    private javax.swing.JLabel passLabel1;
    private javax.swing.JTextField prenomField;
    private javax.swing.JLabel prenomLabel;
    private javax.swing.JTextField pseudoAuto;
    private javax.swing.JTextField pseudoField;
    private javax.swing.JTextField pseudoField1;
    private javax.swing.JLabel pseudoLabel;
    private javax.swing.JLabel pseudoLabel1;
    private javax.persistence.Query query;
    private javax.swing.JMenuItem quitte;
    private javax.swing.JButton refreshButton;
    private javax.swing.JTextField repvignette;
    private javax.swing.JTextField roleField;
    private javax.swing.JLabel roleLabel;
    private javax.swing.JButton saveButton;
    private javax.swing.JTextField validationField;
    private javax.swing.JLabel validationLabel;
    // End of variables declaration//GEN-END:variables
}
